package org.csu.mypetstore.persistence.impl;

import java.sql.*;
public class DBUtil {
    private static String driverString="com.mysql.jdbc.Driver";
    private static String connectionString="jdbc:mysql://localhost:3306/mypetstore";
    private static String username="root";
    private static String password="hp221B";

    public static Connection getConnection() throws Exception {
        Connection connection=null;
        try{
            Class.forName(driverString);
            connection=DriverManager.getConnection(connectionString,username,password);
        }catch (Exception e){
            throw e;
        }
        return connection;

    }
    public static void close(Connection connection,PreparedStatement preparedStatement,ResultSet resultSet) throws SQLException {
        connection.close();
        preparedStatement.close();
        resultSet.close();
    }
    public static void closeStatement(Statement statement) throws SQLException {
        statement.close();
    }

//    public static void main(String[] args) throws Exception {
//        Connection conn=DBUtil.getConnection();
//        System.out.println(conn);
//    }
}
